<template>
    <div>
        <pre>
             testFind(){
                // 数组中元素为对象
                const courses = [
                    { "id": 1, "name": "course1" },
                    { "id": 2, "name": "course2" },
                    { "id": 3, "name": "course3" }
                ];
                console.log(courses);
                //抽取id=1的course
                let course = courses.find(item => item.id === 1);
                console.log(course);
            }
        </pre>
        <button @click="testFind">抽取单行</button>
        <p>{{jstr}}</p>
    </div>
</template>

<script>
    export default {
        name: "es6Find",
        data() {
            return {
                jstr: ''
            }
        },
        methods: {
            testFind() {
                // 数组中元素为对象
                const courses = [
                    {"id": 1, "name": "course1"},
                    {"id": 2, "name": "course2"},
                    {"id": 3, "name": "course3"}
                ];
                console.log(courses);
                let course = courses.find(item => item.id === 1);
                console.log(course);
                this.jstr = JSON.stringify(course);
            }
        }
    }
</script>

<style scoped>

</style>